﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EasyGrocer.DataLayer;

namespace EasyGrocer.BusinessLayer.ServiceRepository
{
    public class CategoryServiceRepImpl:ICategoryServiceRep
    {
        private static EasyGrocerDBDataContext _dc;
        public IEnumerable<Category> GetChildrenById(Guid id)
        {
            _dc = DataContextContainer.CurrentDataContext;
            IEnumerable<Category> categories = _dc.CategoryRelations.Where(a => a.ParentID == id).Select(a => a.Category).OrderBy(d=>d.Name);
            return categories;
        }
        public IEnumerable<Category> GetRootChildren()
        {
            _dc = DataContextContainer.CurrentDataContext;
            return _dc.Categories.OrderBy(d=>d.Name);
        }
        public Category Get(Guid id)
        {
            throw new NotImplementedException();
        }
    }
}
    